#pragma once
#include "HashTable.h"
using namespace LinkHash;

namespace ns_us
{
	template<class K, class HashFunc = Hash<K>>
	class unordered_set
	{
	private:
		struct KeyOfT
		{
			const K& operator()(const K& key)
			{
				return key;
			}
		};

	public:
		typedef typename HashTable<K, K, KeyOfT, HashFunc>::iterator iterator;

		iterator begin()
		{
			return _ht.begin();
		}

		iterator end()
		{
			return _ht.end();
		}

		pair<iterator, bool> insert(const K& key)
		{
			return _ht.insert(key);
		}

	private:
		LinkHash::HashTable<K, K, KeyOfT, HashFunc> _ht;
	};

	void test_unorderedset()
	{
		unordered_set<int> us;
		us.insert(1);
		us.insert(2);
		us.insert(32);
		us.insert(62);
		us.insert(22);
		/*unordered_set<string> us;
		us.insert("hello");
		us.insert("nihao");
		us.insert("left");*/

		auto it = us.begin();
		while (it != us.end())
		{
			cout << *it << " ";
			++it;
		}
		cout << endl;
	}
}